home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-12 | 28.8 KB | 878 lines | [TEXT/CWIE] |
- unit WEInterface;
-
- { WASTE PROJECT: }
- { Internal interface: private constants and data types }
-
- { Copyright © 1993-1995 Marco Piovanelli }
- { All Rights Reserved }
-
- interface
- uses
- ConditionalMacros, Types, Memory, Events, Fonts, Quickdraw, QuickdrawText, Script, TextUtils, TextServices, Drag, WELongCoords, WEUtilities;
-
- { compiler switches }
-
- { set WASTE_DEBUG to TRUE to perform miscellaneous asserts and sanity checks }
-
- {$IFC UNDEFINED WASTE_DEBUG}
- {$SETC WASTE_DEBUG = FALSE}
- {$ENDC}
-
- { set WASTE_SEGMENT to TRUE to build a multi-segment library }
- { using the $S segmentation directive }
-
- {$IFC UNDEFINED WASTE_SEGMENT}
- {$SETC WASTE_SEGMENT = FALSE}
- {$ENDC}
-
- const
-
- { result codes }
-
- weCantUndoErr = -10015; { undo buffer is clear (= errAECantUndo) }
- weEmptySelectionErr = -10013; { empty selection range (= errAENoUserSelection) }
- weUnknownObjectTypeErr = -9478; { specified object type was not registered }
- weObjectNotFoundErr = -9477; { no object found at specified offset }
- weReadOnlyErr = -9476; { instance is read-only }
-
- { alignment styles }
-
- weFlushLeft = -2;
- weFlushRight = -1;
- weFlushDefault = 0;
- weCenter = 1;
- weJustify = 2;
-
- { values for the edge parameter }
-
- kLeadingEdge = -1; { point is on the leading edge of a glyph }
- kTrailingEdge = 0; { point is on the trailing edge of a glyph }
- kObjectEdge = 2; { point is inside an embedded object }
-
- { control character codes }
-
- kObjectMarker = 1;
- kBackspace = 8;
- kTab = 9;
- kEOL = 13;
- kSpace = 32;
- kArrowLeft = 28;
- kArrowRight = 29;
- kArrowUp = 30;
- kArrowDown = 31;
- kForwardDelete = 127;
-
- { bit equates for QuickDraw styles }
-
- tsBold = 0;
- tsItalic = 1;
- tsUnderline = 2;
- tsOutline = 3;
- tsShadow = 4;
- tsCondense = 5;
- tsExtend = 6;
-
- { bit equates for the tsFlags field of the WETextStyle record }
-
- tsTSMHilite = 4; { set if style run is part of active input area }
- tsTSMSelected = 5; { set for selected raw/converted text }
- tsTSMConverted = 6; { set for converted text, clear for raw text }
- tsRightToLeft = 7; { specifies style run direction }
-
- { bit equates for the mode parameter in WESetStyle and WEContinuousStyle }
-
- kModeFont = 0;
- kModeFace = 1;
- kModeSize = 2;
- kModeColor = 3;
- kModeAddSize = 4;
- kModeToggleFace = 5;
- kModeReplaceFace = 6;
- kModeObject = 14;
- kModeFlags = 15;
-
- { values for the mode parameter in WESetStyle and WEContinuousStyle }
-
- weDoFont = $0001;
- weDoFace = $0002;
- weDoSize = $0004;
- weDoColor = $0008;
- weDoAll = weDoFont + weDoFace + weDoSize + weDoColor;
- weDoAddSize = $0010;
- weDoToggleFace = $0020;
- weDoReplaceFace = $0040;
- weDoObject = $4000;
- weDoFlags = $8000;
-
- { values for WEFeatureFlag action parameter }
-
- weBitToggle = -2; { toggles the specified feature }
- weBitTest = -1; { returns the current setting of the specified feature }
- weBitClear = 0; { disables the specified feature }
- weBitSet = 1; { enables the specified feature }
-
- { bit equates for the flags field in the WE record }
- { bits 0..15 can be used to turn on and off specific features with WEFeatureFlag }
- { bits 16..31 are used internally and should not be modified }
-
- weFHasColorQD = 31; { Color QuickDraw is available }
- weFHasTextServices = 30; { Text Services Manager is available }
- weFNonRoman = 29; { At least one non-Roman script is enabled }
- weFDoubleByte = 28; { A double-byte script is installed }
- weFHasDragManager = 27; { Drag Manager is available }
- weFCaretVisible = 24; { Caret is currently visible }
- weFMouseTracking = 23; { Set internally during mouse tracking }
- weFAnchorIsEnd = 22; { Anchor offset is selEnd }
- weFUseNullStyle = 21; { A null style is associated with the empty selection }
- weFActive = 20; { TRUE if text pane is active }
- weFHilited = 19; { TRUE if text pane is highlighted (for Drag & Drop) }
- weFCanAcceptDrag = 18; { The drag in the text pane can be accepted }
- weFDragCaretVisible = 17; { Drag caret is currently visible }
- weFDestRectChanged = 16; { Set if scroll callback needs to be called }
-
- weFDrawOffscreen = 11; { Draw text offscreen for smoother visual results }
- weFUseTempMem = 10; { Use temporary memory }
- weFInhibitRecal = 9; { If set, recals and redraws are inhibited }
- weFDragAndDrop = 8; { Support Drag and Drop }
- weFIntCutAndPaste = 7; { Intelligent Cut & Paste }
- weFUndoSupport = 6; { Support Undo/Redo }
- weFReadOnly = 5; { Disallow editing }
- weFOutlineHilite = 2; { Outline selection range when text pane is inactive }
- weFAutoScroll = 0; { Automatically scroll text when cursor is outside pane }
-
- { scrap types }
-
- kTypeText = 'TEXT';
- kTypeStyles = 'styl';
- kTypeSoup = 'SOUP';
-
- { selectors for WEGetInfo/WESetInfo }
-
- weCharByteHook = 'cbyt';
- weCharTypeHook = 'ctyp';
- weCharToPixelHook = 'c2p ';
- weClickLoop = 'clik';
- weCurrentDrag = 'drag';
- weDrawTextHook = 'draw';
- weLineArray = 'line';
- weLineBreakHook = 'lbrk';
- wePixelToCharHook = 'p2c ';
- wePort = 'port';
- weRefCon = 'refc';
- weRunArray = 'runa';
- weScrollProc = 'scrl';
- weStyleTable = 'styl';
- weText = 'text';
- weTranslateDragHook = 'xdrg';
- weTSMDocumentID = 'tsmd';
- weTSMPostUpdate = 'post';
- weTSMPreUpdate = 'pre ';
-
- { possible values returned by WEIntelligentPaste }
-
- weDontAddSpaces = 0;
- weAddSpaceOnLeftSide = -1;
- weAddSpaceOnRightSide = 1;
-
- { other miscellaneous constants }
-
- kCaretWidth = 1; { width of the caret, in pixels }
- kMinFontSize = 1; { minimum valid value for the font size }
- kMaxFontSize = maxint; { maximum valid value for the font size }
- kOneToOneScaling = $00010001; { 1:1 scaling ratio }
- kInvalidOffset = -1; { used to flag an invalid or nonexistent offset }
- kNullDrag = 0; { null or nonexistent drag reference }
- kNullObject = 0; { null object reference }
-
- type
-
- WEChars = packed array[0..999999] of Char;
- WECharsPtr = ^WEChars;
- WECharsHandle = ^WECharsPtr;
-
- DoubleByte = packed record
- firstByte: SignedByte;
- secondByte: SignedByte;
- end; { DoubleByte }
-
- WETextStyle = record
- case Integer of
- 0: (
- tsFont: Integer;
- tsFace: SignedByte;
- tsFlags: SignedByte;
- tsSize: Integer;
- tsColor: RGBColor;
- );
- 1: (
- tsTEStyle: TextStyle; { TextEdit style attributes }
- tsObject: LongInt; { embedded object reference }
- );
- end; { WETextStyle }
- WETextStylePtr = ^WETextStyle;
-
- TERunAttributes = record
- runHeight: Integer;
- runAscent: Integer;
- runTEStyle: TextStyle;
- end; { TERunAttributes }
- TERunAttributesPtr = ^TERunAttributes;
-
- TEStyleScrapElement = record
- scrpStartChar: LongInt;
- scrpTEAttrs: TERunAttributes;
- end; { TEStyleScrapElement }
- TEStyleScrapElementPtr = ^TEStyleScrapElement;
-
- TEStyleScrap = record
- scrpNStyles: Integer;
- scrpStyleTab: array[0..0] of TEStyleScrapElement;
- end;
- TEStyleScrapPtr = ^TEStyleScrap;
- TEStyleScrapHandle = ^TEStyleScrapPtr;
-
- WERunAttributes = record
- case Integer of
- 0: (
- runHeight: Integer; { run height (ascent + descent + leading) }
- runAscent: Integer; { font ascent }
- runStyle: WETextStyle;
- );
- 1: (
- runTEAttrs: TERunAttributes;
- );
- end; { WERunAttributes }
- WERunAttributesPtr = ^WERunAttributes;
-
- WERunInfo = record
- runStart: LongInt;
- runEnd: LongInt;
- runAttrs: WERunAttributes;
- end; { WERunInfo }
- WERunInfoPtr = ^WERunInfo;
-
- GrafPort1 = record
- device: Integer;
- portBits: BitMap;
- portRect: Rect;
- visRgn: RgnHandle;
- clipRgn: RgnHandle;
- bkPat: Pattern;
- fillPat: Pattern;
- pnLoc: Point;
- pnSize: Point;
- pnMode: Integer;
- pnPat: Pattern;
- pnVis: Integer;
- txFont: Integer;
- txFace: SignedByte;
- filler: SignedByte;
- txMode: Integer;
- txSize: Integer;
- spExtra: Fixed;
- fgColor: LongInt;
- bkColor: LongInt;
- colrBit: Integer;
- patStretch: Integer;
- picSave: Handle;
- rgnSave: Handle;
- polySave: Handle;
- grafProcs: QDProcsPtr;
- end; { GrafPort1 }
- GrafPtr1 = ^GrafPort1;
-
- QDEnvironment = record
- envPort: GrafPtr;
- envPen: PenState;
- envStyle: WETextStyle;
- envMode: Integer;
- end; { QDEnvironment }
-
- TEStyleScrapPair = record
- first: TEStyleScrapElement;
- second: TEStyleScrapElement;
- end; { TEStyleScrapPair }
- TEStyleScrapPeek = ^TEStyleScrapPair;
-
- RunArrayElement = record
- runStart: LongInt; { offset to first character in style run }
- styleIndex: LongInt; { index into style table }
- end; { RunArrayElement }
- RunArrayElementPtr = ^RunArrayElement;
- RunArrayElementHandle = ^RunArrayElementPtr;
-
- RunArrayPair = record
- first: RunArrayElement;
- second: RunArrayElement;
- end; { RunArrayPair }
- RunArrayPeek = ^RunArrayPair; { useful to "peek" at a portion of the run array }
-
- const
- kRunArrayMaxIndex = (maxLongInt div SizeOf(RunArrayElement)) - 1;
-
- type
- RunArray = array[0..kRunArrayMaxIndex] of RunArrayElement;
- RunArrayPtr = ^RunArray;
- RunArrayHandle = ^RunArrayPtr;
-
- StyleTableElement = record
- refCount: LongInt; { reference count }
- info: WERunAttributes; { style information }
- end; { StyleTableElement }
- StyleTableElementPtr = ^StyleTableElement;
- StyleTableElementHandle = ^StyleTableElementPtr;
-
- const
- kStyleTableMaxIndex = (maxint div SizeOf(StyleTableElement)) - 1;
-
- type
- StyleTable = array[0..kStyleTableMaxIndex] of StyleTableElement;
- StyleTablePtr = ^StyleTable;
- StyleTableHandle = ^StyleTablePtr;
-
- LineRec = record
- lineStart: LongInt; { offset to first character in line }
- lineOrigin: LongInt; { distance from destRect.top, in pixels }
- lineAscent: Integer; { maximum font ascent for this line, in pixels }
- lineSlop: Integer; { extra pixels needed to fill up the line }
- lineJustAmount: Fixed; { normalized slop value for justification }
- end; { LineRec }
- LinePtr = ^LineRec;
- LineHandle = ^LinePtr;
-
- LinePair = record
- first: LineRec;
- second: LineRec;
- end; { LinePair }
- LinePeek = ^LinePair; { useful to "peek" at a portion of the line array }
-
- const
- kLineArrayMaxIndex = (maxLongInt div SizeOf(LineRec)) - 1;
-
- type
- LineArray = array[0..kLineArrayMaxIndex] of LineRec;
- LineArrayPtr = ^LineArray;
- LineArrayHandle = ^LineArrayPtr;
-
- { Procedure Pointers & UPPs }
-
- type
-
- { FUNCTION MyClickLoop(hWE: WEHandle): Boolean; }
- WEClickLoopProcPtr = ProcPtr;
- WEClickLoopUPP = UniversalProcPtr;
-
- { PROCEDURE MyScroll(hWE: WEHandle); }
- WEScrollProcPtr = ProcPtr;
- WEScrollUPP = UniversalProcPtr;
-
- { PROCEDURE MyTSMPreUpdate(hWE: WEHandle); }
- WETSMPreUpdateProcPtr = ProcPtr;
- WETSMPreUpdateUPP = UniversalProcPtr;
-
- { PROCEDURE MyTSMPostUpdate(hWE: WEHandle; fixLength: LongInt; }
- { inputAreaStart, inputAreaEnd: LongInt; pinRangeStart, pinRangeEnd: LongInt); }
- WETSMPostUpdateProcPtr = ProcPtr;
- WETSMPostUpdateUPP = UniversalProcPtr;
-
- { FUNCTION MyTranslateDrag (theDrag: DragReference; theItem: ItemReference; }
- { requestedType: FlavorType; putDataHere: Handle): OSErr; }
- WETranslateDragProcPtr = ProcPtr;
- WETranslateDragUPP = UniversalProcPtr;
-
- { PROCEDURE MyDrawText (pText: Ptr; textLength: LongInt; slop: Fixed; }
- { styleRunPosition: JustStyleCode; hWE: WEHandle); }
- WEDrawTextProcPtr = ProcPtr;
- WEDrawTextUPP = UniversalProcPtr;
-
- { FUNCTION MyPixelToChar (pText: Ptr; textLength: LongInt; slop: Fixed; }
- { VAR pixelWidth: Fixed; VAR edge: SignedByte; }
- { styleRunPosition: JustStyleCode; hPos: Fixed; hWE: WEHandle): LongInt; }
- WEPixelToCharProcPtr = ProcPtr;
- WEPixelToCharUPP = UniversalProcPtr;
-
- { FUNCTION MyCharToPixel (pText: Ptr; textLength: LongInt; slop: Fixed; }
- { offset: LongInt; direction: Integer; }
- { styleRunPosition: JustStyleCode; hPos: LongInt; hWE:WEHandle): Integer; }
- WECharToPixelProcPtr = ProcPtr;
- WECharToPixelUPP = UniversalProcPtr;
-
- { FUNCTION MyLineBreak (pText: Ptr; textLength: LongInt; }
- { textStart, textEnd: LongInt; VAR textWidth: Fixed; VAR textOffset: LongInt; }
- { hWE: WEHandle): StyledLineBreakCode; }
- WELineBreakProcPtr = ProcPtr;
- WELineBreakUPP = UniversalProcPtr;
-
- { PROCEDURE MyWordBreak (pText: Ptr; textLength: Integer; }
- { offset: Integer; edge: SignedByte; VAR breakOffsets: OffsetTable; }
- { script: ScriptCode; hWE: WEHandle); }
- WEWordBreakProcPtr = ProcPtr;
- WEWordBreakUPP = UniversalProcPtr;
-
- { FUNCTION MyCharByte (pText: Ptr; textOffset: Integer; }
- { script: ScriptCode; hWE: WEHandle): Integer; }
- WECharByteProcPtr = ProcPtr;
- WECharByteUPP = UniversalProcPtr;
-
- { FUNCTION MyCharType (pText: Ptr; textOffset: Integer; }
- { script: ScriptCode; hWE: WEHandle): Integer; }
- WECharTypeProcPtr = ProcPtr;
- WECharTypeUPP = UniversalProcPtr;
-
- { UPP proc info }
-
- const
-
- uppWEClickLoopProcInfo = $000000D0;
- uppWEScrollProcInfo = $000000C0;
- uppWETSMPreUpdateProcInfo = $000000C0;
- uppWETSMPostUpdateProcInfo = $0003FFC0;
- uppWETranslateDragProcInfo = $00003FE0;
- uppWEDrawTextProcInfo = $0000EFC0;
- uppWEPixelToCharProcInfo = $003EFFF0;
- uppWECharToPixelProcInfo = $003EBFE0;
- uppWELineBreakProcInfo = $000FFFD0;
- uppWEWordBreakProcInfo = $000EDAC0;
- uppWECharByteProcInfo = $00003AE0;
- uppWECharTypeProcInfo = $00003AE0;
-
- type
-
- WERec = record
- port: GrafPtr; { graphics port }
- hText: Handle; { handle to the raw text }
- hLines: LineArrayHandle; { handle to the line array }
- hStyles: StyleTableHandle; { handle to the style table }
- hRuns: RunArrayHandle; { handle to the style run array }
- textLength: LongInt; { length of raw text block }
- nLines: LongInt; { number of lines }
- nStyles: LongInt; { number of distinct styles in the style table }
- nRuns: LongInt; { number of style runs in the style run array }
- viewRect: LongRect; { view rectangle }
- destRect: LongRect; { destination rectangle }
- selStart: LongInt; { start of selection range }
- selEnd: LongInt; { end of selection range }
- flags: LongInt; { 32 bits of miscellaneous flags }
- caretTime: LongInt; { time of most recent caret xoring }
- clickTime: LongInt; { time of most recent click }
- clickLoc: LongInt; { byte offset of most recent click }
- anchorStart: LongInt; { anchor word start }
- anchorEnd: LongInt; { anchor word end }
- clickLoop: WEClickLoopUPP; { click loop callback }
- unused1: SignedByte; { unused }
- clickEdge: SignedByte; { edge of character hit by most recent click }
- unused2: SignedByte; { unused }
- firstByte: SignedByte; { first byte of a double-byte character }
- offscreenPort: GrafPtr; { offscreen graphics world }
- viewRgn: RgnHandle; { handle to the view region }
- scrollProc: WEScrollUPP; { scroll callback }
- clickCount: Integer; { multiple click count }
- alignment: Integer; { alignment style }
- refCon: LongInt; { reference value for client use }
- tsmReference: TSMDocumentID; { Text Services Manager document ID }
- tsmAreaStart: LongInt; { start of active inline input area }
- tsmAreaEnd: LongInt; { end of active inline input area }
- tsmPreUpdate: WETSMPreUpdateUPP; { called before handling a TSM updt event }
- tsmPostUpdate: WETSMPostUpdateUPP; { called after handling a TSM updt event }
- currentDrag: DragReference; { reference of drag being tracked by _WEDrag }
- dragCaretOffset: LongInt; { offset to caret displayed during a drag }
- translateDragHook: WETranslateDragUPP; { drag translation hook }
- hActionStack: Handle; { action stack for undo }
- modCount: LongInt; { modification count }
- drawTextHook: WEDrawTextUPP; { hook for drawing text }
- pixelToCharHook: WEPixelToCharUPP; { hook for hit-testing }
- charToPixelHook: WECharToPixelUPP; { hook for locating glyph position }
- lineBreakHook: WELineBreakUPP; { hook for finding line breaks }
- wordBreakHook: WEWordBreakUPP; { hook for finding word breaks }
- charByteHook: WECharByteUPP; { hook for finding character byte type }
- charTypeHook: WECharTypeUPP; { hook for finding character type }
- hObjectHandlerTable: Handle; { handle to object handler table for this instance }
- nullStyle: WERunAttributes; { style for null selection }
- end; { WERec }
- WEPtr = ^WERec;
- WEHandle = ^WEPtr;
-
- { NewProc macros }
-
- function NewWEClickLoopProc (userRoutine: WEClickLoopProcPtr): WEClickLoopUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWEScrollProc (userRoutine: WEScrollProcPtr): WEScrollUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWETSMPreUpdateProc (userRoutine: WETSMPreUpdateProcPtr): WETSMPreUpdateUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWETSMPostUpdateProc (userRoutine: WETSMPostUpdateProcPtr): WETSMPostUpdateUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWETranslateDragProc (userRoutine: WETranslateDragProcPtr): WETranslateDragUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWEDrawTextProc (userRoutine: WEDrawTextProcPtr): WEDrawTextUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWEPixelToCharProc (userRoutine: WEPixelToCharProcPtr): WEPixelToCharUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWECharToPixelProc (userRoutine: WECharToPixelProcPtr): WECharToPixelUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWELineBreakProc (userRoutine: WELineBreakProcPtr): WELineBreakUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWEWordBreakProc (userRoutine: WEWordBreakProcPtr): WEWordBreakUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWECharByteProc (userRoutine: WECharByteProcPtr): WECharByteUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- function NewWECharTypeProc (userRoutine: WECharTypeProcPtr): WECharTypeUPP;
- {$IFC NOT GENERATINGCFM}
- inline
- $2E9F;
- {$ENDC}
-
- { CallProc macros }
-
- function CallWEClickLoopProc (hWE: WEHandle;
- userRoutine: WEClickLoopUPP): Boolean;
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- procedure CallWEScrollProc (hWE: WEHandle;
- userRoutine: WEScrollUPP);
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- procedure CallWETSMPreUpdateProc (hWE: WEHandle;
- userRoutine: WETSMPreUpdateUPP);
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- procedure CallWETSMPostUpdateProc (hWE: WEHandle;
- fixLength: LongInt;
- inputAreaStart, inputAreaEnd: LongInt;
- pinRangeStart, pinRangeEnd: LongInt;
- userRoutine: WETSMPostUpdateUPP);
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- function CallWETranslateDragProc (theDrag: DragReference;
- theItem: ItemReference;
- requestedType: FlavorType;
- putDataHere: Handle;
- userRoutine: WETranslateDragUPP): OSErr;
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- procedure CallWEDrawTextProc (pText: Ptr;
- textLength: LongInt;
- slop: Fixed;
- styleRunPosition: JustStyleCode;
- hWE: WEHandle;
- userRoutine: WEDrawTextUPP);
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- function CallWEPixelToCharProc (pText: Ptr;
- textLength: LongInt;
- slop: Fixed;
- var width: Fixed;
- var edge: SignedByte;
- styleRunPosition: JustStyleCode;
- hPos: Fixed;
- hWE: WEHandle;
- userRoutine: WEPixelToCharUPP): LongInt;
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- function CallWECharToPixelProc (pText: Ptr;
- textLength: LongInt;
- slop: Fixed;
- offset: LongInt;
- direction: Integer;
- styleRunPosition: JustStyleCode;
- hPos: LongInt;
- hWE: WEHandle;
- userRoutine: WECharToPixelUPP): Integer;
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- function CallWELineBreakProc (pText: Ptr;
- textLength: LongInt;
- textStart, textEnd: LongInt;
- var textWidth: Fixed;
- var textOffset: LongInt;
- hWE: WEHandle;
- userRoutine: WELineBreakUPP): StyledLineBreakCode;
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- procedure CallWEWordBreakProc (pText: Ptr;
- textLength: Integer;
- offset: Integer;
- edge: SignedByte;
- var breakOffsets: OffsetTable;
- script: ScriptCode;
- hWE: WEHandle;
- userRoutine: WEWordBreakUPP);
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- function CallWECharByteProc (pText: Ptr;
- textOffset: Integer;
- script: ScriptCode;
- hWE: WEHandle;
- userRoutine: WECharByteUPP): Integer;
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
- function CallWECharTypeProc (pText: Ptr;
- textOffset: Integer;
- script: ScriptCode;
- hWE: WEHandle;
- userRoutine: WECharTypeUPP): Integer;
- {$IFC NOT GENERATINGCFM}
- inline
- $205F, $4E90;
- {$ENDC}
-
-
- { The following declaration lets me pass SignedByte quantities to TextFace. }
- { Without this trick, the WASTE.o library would end up containing }
- { references to some THINK Pascal runtime routines for set manipulation }
- { and such references are very likely to cause link errors when including }
- { the library from other development environments. }
-
- {$IFC NOT GENERATINGCFM}
- procedure __TextFace (face: Integer);
- inline
- $A888;
- {$ELSEC}
- procedure __TextFace (face: SignedByte);
- {$ENDC}
-
- { GetQDGlobalsPtr lets me access Quickdraw globals directly from the A5 register }
- { without referencing external variables like "qd" (not defined by THINK Pascal) }
- { or "thePort" (not defined by newer compilers) }
-
- const
- kQDGlobalsOffset = SizeOf(GrafPtr) - SizeOf(QDGlobals);
-
- type
- QDGlobalsPtr = ^QDGlobals;
-
- function GetQDGlobalsPtr: QDGlobalsPtr;
- {$IFC NOT GENERATINGCFM}
- inline
- $2055, $41E8, kQDGlobalsOffset, $2E88;
- {$ENDC}
-
- implementation
- {$IFC GENERATINGCFM}
- uses
- MixedMode;
-
- { NewXProc glue needed for the Code Fragment Manager }
- { (the CallXProc glue can't be written using Metrowerks Pascal) }
-
- function NewWEClickLoopProc (userRoutine: WEClickLoopProcPtr): WEClickLoopUPP;
- begin
- NewWEClickLoopProc := NewRoutineDescriptor(userRoutine, uppWEClickLoopProcInfo, GetCurrentArchitecture);
- end; { NewWEClickLoopProc }
-
- function NewWEScrollProc (userRoutine: WEScrollProcPtr): WEScrollUPP;
- begin
- NewWEScrollProc := NewRoutineDescriptor(userRoutine, uppWEScrollProcInfo, GetCurrentArchitecture);
- end; { NewWEScrollProc }
-
- function NewWETSMPreUpdateProc (userRoutine: WETSMPreUpdateProcPtr): WETSMPreUpdateUPP;
- begin
- NewWETSMPreUpdateProc := NewRoutineDescriptor(userRoutine, uppWETSMPreUpdateProcInfo, GetCurrentArchitecture);
- end; { NewWETSMPreUpdateProc }
-
- function NewWETSMPostUpdateProc (userRoutine: WETSMPostUpdateProcPtr): WETSMPostUpdateUPP;
- begin
- NewWETSMPostUpdateProc := NewRoutineDescriptor(userRoutine, uppWETSMPostUpdateProcInfo, GetCurrentArchitecture);
- end; { NewWETSMPostUpdateProc }
-
- function NewWETranslateDragProc (userRoutine: WETranslateDragProcPtr): WETranslateDragUPP;
- begin
- NewWETranslateDragProc := NewRoutineDescriptor(userRoutine, uppWETranslateDragProcInfo, GetCurrentArchitecture);
- end; { NewWETranslateDragProc }
-
- function NewWEDrawTextProc (userRoutine: WEDrawTextProcPtr): WEDrawTextUPP;
- begin
- NewWEDrawTextProc := NewRoutineDescriptor(userRoutine, uppWEDrawTextProcInfo, GetCurrentArchitecture);
- end; { NewWEDrawTextProc }
-
- function NewWEPixelToCharProc (userRoutine: WEPixelToCharProcPtr): WEPixelToCharUPP;
- begin
- NewWEPixelToCharProc := NewRoutineDescriptor(userRoutine, uppWEPixelToCharProcInfo, GetCurrentArchitecture);
- end; { NewWEPixelToCharProc }
-
- function NewWECharToPixelProc (userRoutine: WECharToPixelProcPtr): WECharToPixelUPP;
- begin
- NewWECharToPixelProc := NewRoutineDescriptor(userRoutine, uppWECharToPixelProcInfo, GetCurrentArchitecture);
- end; { NewWECharToPixelProc }
-
- function NewWELineBreakProc (userRoutine: WELineBreakProcPtr): WELineBreakUPP;
- begin
- NewWELineBreakProc := NewRoutineDescriptor(userRoutine, uppWELineBreakProcInfo, GetCurrentArchitecture);
- end; { NewWELineBreakProc }
-
- function NewWEWordBreakProc (userRoutine: WEWordBreakProcPtr): WEWordBreakUPP;
- begin
- NewWEWordBreakProc := NewRoutineDescriptor(userRoutine, uppWEWordBreakProcInfo, GetCurrentArchitecture);
- end; { NewWEWordBreakProc }
-
- function NewWECharByteProc (userRoutine: WECharByteProcPtr): WECharByteUPP;
- begin
- NewWECharByteProc := NewRoutineDescriptor(userRoutine, uppWECharByteProcInfo, GetCurrentArchitecture);
- end; { NewWECharByteProc }
-
- function NewWECharTypeProc (userRoutine: WECharTypeProcPtr): WECharTypeUPP;
- begin
- NewWECharTypeProc := NewRoutineDescriptor(userRoutine, uppWECharTypeProcInfo, GetCurrentArchitecture);
- end; { NewWECharTypeProc }
-
- function CallWEClickLoopProc(hWE: WEHandle; userRoutine: WEClickLoopUPP): Boolean;
- begin
- CallWEClickLoopProc := Boolean(CallUniversalProc(userRoutine, uppWEClickLoopProcInfo, hWE));
- end; { CallWEClickLoopProc }
-
- procedure CallWEScrollProc(hWE: WEHandle; userRoutine: WEScrollUPP);
- var
- retval: LongInt;
- begin
- retval := CallUniversalProc(userRoutine, uppWEClickLoopProcInfo, hWE);
- end; { CallWEScrollProc }
-
- procedure CallWETSMPreUpdateProc(hWE: WEHandle; userRoutine: WETSMPreUpdateUPP);
- var
- retval: LongInt;
- begin
- retval := CallUniversalProc(userRoutine, uppWETSMPreUpdateProcInfo, hWE);
- end; { CallWETSMPreUpdateProc }
-
- procedure CallWETSMPostUpdateProc(hWE: WEHandle; fixLength: LongInt; inputAreaStart: LongInt; inputAreaEnd: LongInt; pinRangeStart: LongInt; pinRangeEnd: LongInt; userRoutine: WETSMPostUpdateUPP);
- var
- retval: LongInt;
- begin
- retval := CallUniversalProc(userRoutine, uppWETSMPostUpdateProcInfo, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd);
- end; { CallWETSMPostUpdateProc }
-
- function CallWETranslateDragProc(theDrag: DragReference; theItem: ItemReference; requestedType: FlavorType; putDataHere: Handle; userRoutine: WETranslateDragUPP): OSErr;
- begin
- CallWETranslateDragProc := CallUniversalProc(userRoutine, uppWETranslateDragProcInfo, theDrag, theItem, requestedType, putDataHere);
- end; { CallWETranslateDragProc }
-
- procedure CallWEDrawTextProc(pText: Ptr; textLength: LongInt; slop: Fixed; styleRunPosition: JustStyleCode; hWE: WEHandle; userRoutine: WEDrawTextUPP);
- var
- retval: LongInt;
- begin
- retval := CallUniversalProc(userRoutine, uppWEDrawTextProcInfo, pText, textLength, slop, styleRunPosition, hWE);
- end; { CallWEDrawTextProc }
-
- function CallWEPixelToCharProc(pText: Ptr; textLength: LongInt; slop: Fixed; var pixelWidth: Fixed; var edge: SignedByte; styleRunPosition: JustStyleCode; hPos: Fixed; hWE: WEHandle; userRoutine: WEPixelToCharUPP): LongInt;
- begin
- CallWEPixelToCharProc := CallUniversalProc((userRoutine), uppWEPixelToCharProcInfo, pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, hWE);
- end; { CallWEPixelToCharProc }
-
- function CallWECharToPixelProc(pText: Ptr; textLength: LongInt; slop: Fixed; offset: LongInt; direction: Integer; styleRunPosition: JustStyleCode; hPos: LongInt; hWE: WEHandle; userRoutine: WECharToPixelUPP): Integer;
- begin
- CallWECharToPixelProc := CallUniversalProc(userRoutine, uppWECharToPixelProcInfo, pText, textLength, slop, offset, direction, styleRunPosition, hPos, hWE);
- end; { CallWECharToPixelProc }
-
- function CallWELineBreakProc(pText: Ptr; textLength: LongInt; textStart: LongInt; textEnd: LongInt; var textWidth: Fixed; var textOffset: LongInt; hWE: WEHandle; userRoutine: WELineBreakUPP): StyledLineBreakCode;
- begin
- CallWELineBreakProc := CallUniversalProc(userRoutine, uppWELineBreakProcInfo, pText, textLength, textStart, textEnd, textWidth, textOffset, hWE);
- end; { CallWELineBreakProc }
-
- procedure CallWEWordBreakProc(pText: Ptr; textLength: Integer; offset: Integer; edge: SignedByte; var breakOffsets: OffsetTable; script: ScriptCode; hWE: WEHandle; userRoutine: WEWordBreakUPP);
- var
- retval: LongInt;
- begin
- retval := CallUniversalProc(userRoutine, uppWEWordBreakProcInfo, pText, textLength, offset, edge, breakOffsets, script, hWE);
- end; { CallWEWordBreakProc }
-
- function CallWECharByteProc(pText: Ptr; textOffset: Integer; script: ScriptCode; hWE: WEHandle; userRoutine: WECharByteUPP): Integer;
- begin
- CallWECharByteProc := CallUniversalProc(userRoutine, uppWECharByteProcInfo, pText, textOffset, script, hWE);
- end; { CallWECharByteProc }
-
- function CallWECharTypeProc(pText: Ptr; textOffset: Integer; script: ScriptCode; hWE: WEHandle; userRoutine: WECharTypeUPP): Integer;
- begin
- CallWECharTypeProc := CallUniversalProc(userRoutine, uppWECharTypeProcInfo, pText, textOffset, script, hWE);
- end; { CallWECharTypeProc }
-
- procedure __TextFace (face: SignedByte);
- type
- StylePtr = ^Style;
- begin
- TextFace(StylePtr(@face)^);
- end; { __TextFace }
-
- function GetQDGlobalsPtr: QDGlobalsPtr;
- begin
- GetQDGlobalsPtr := @qd;
- end; { GetQDGlobalsPtr }
-
- {$ENDC}
- end.